function login(){
  var username = jQuery("#username");
  var password = jQuery("#password");
  // 1. 非空校验
  if(jQuery.trim(username.val())==''){
      alert("请先输入账号！");
      // 让光标显示到用户名
      username.focus();
      return;
  }
  if(jQuery.trim(password.val())==''){
      alert("请先输入密码！");
      // 让光标显示到密码
      password.focus();
      return;
  }
  // 2. 将数据提交给后端（SpringBoot）
  jQuery.ajax({
      url: 'login',
      method: 'post',
      contentType:'application/json',
      data: JSON.stringify(
        {
          username:username.val(),
          password:password.val()
       }),
      dataType:'json',
      success: function(result){
        if(result != null){
          if(result.code==200){
              alert("登录成功！");
              //保存信息到本地，里面都token
              localStorage.setItem("token", result.data.token);
              if(result.data.admin == 0){
                location.href = "home.html";
              }else{
                location.href = "bake-stage.html";
              }
          }else{
              alert("登录失败，" + result.msg);
          }
        }else{
              alert("后端服务不可用！");
        }
      }
  });
}